package com.itheima.consumer.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FanoutConfiguration {

    //声明交换机方式一  方式二为直接在选择监听队列时使用注解进行创建
    @Bean
    public FanoutExchange fanoutExchange() {
        return new FanoutExchange("hmall.fanout2");
    }

    //声明队列
    @Bean
    public Queue fanoutQueue3() {
        return new Queue("fanout.queue3");
    }

    //声明绑定
    @Bean
    public Binding fanoutBinding3(@Qualifier("fanoutQueue3") Queue fanoutQueue3, FanoutExchange fanoutExchange) {
        return BindingBuilder.bind(fanoutQueue3).to(fanoutExchange);

    }

}
